package com.yeh.common.util;

import javax.servlet.http.HttpSession;

import com.yeh.model.po.SysUser;

/**
 * 
 * <p>Title: UserUtil</p>
 * <p>Description: 用户工具类</p>
 * <p>Company:  Co.</p>
 * <p>Package: com.yeh.util</p>
 * @author <a href="mailto:yehshuai@126.com">叶帅</a>  
 * <p>DateTime: 2015年8月28日 ★  上午10:02:39</p> 
 * @Version V1.0.0
 */
public class UserUtil {
	
	public static final String USER = "user";
	
	/**
	 * @Title: saveUserToSession
	 * @Description: 设置用户到Sesion
	 * @param @param session
	 * @param @param user    
	 * @return void
	 * @throws
	 */
	public static void saveUserToSession(HttpSession session,SysUser user){
		session.setAttribute(USER, user);
	}

	/**
	 * @Title: getUserFromSession
	 * @Description: 从Session中获取当前用户信息
	 * @param @param session
	 * @param @return    
	 * @return User
	 * @throws
	 */
	public static SysUser getUserFromSession(HttpSession session){
		Object attribute = session.getAttribute(USER);
		return attribute == null ? null : (SysUser)attribute;
	}
}
